package com.study.controller;

import com.study.domain.Role;
import com.study.service.RoleService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by think on 2016/7/28.
 */
@Controller
@RequestMapping("/role")
public class RoleController {
    @Resource
    private RoleService roleService;

    @RequestMapping("/getRoles")
    @ResponseBody
    public List<Role> getRoles(HttpServletRequest request,HttpServletResponse response){
        String idStr = request.getParameter("id");
        int id = idStr == null ? 0 :Integer.valueOf(idStr);
        return roleService.getRoles(id);
    }
}
